Skip to content

fix(tui): copy selection on Cmd+C when copy-on-select is disabled#27059

Closed
astron8t-voyagerx wants to merge 1 commit into
anomalyco:devfrom
astron8t-voyagerx:fix/cmd-c-copy-on-select-disabled
Closed

fix(tui): copy selection on Cmd+C when copy-on-select is disabled#27059
astron8t-voyagerx wants to merge 1 commit into
anomalyco:devfrom
astron8t-voyagerx:fix/cmd-c-copy-on-select-disabled

Conversation

@astron8t-voyagerx

@astron8t-voyagerx astron8t-voyagerx commented May 12, 2026

Copy link
Copy Markdown

Issue for this PR

Closes #27058

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

In handleSelectionKey (packages/opencode/src/cli/cmd/tui/util/selection.ts), the copy shortcut only matched event.ctrl. opencode enables the Kitty Keyboard Protocol (useKittyKeyboard: {} in app.tsx), so macOS Cmd+C reaches the app as event.super — but no branch matched, and the function fell through to renderer.clearSelection(), wiping the highlight without copying.

Fix: accept meta and super in addition to ctrl. The SelectionKeyEvent type is widened to mirror the actual KeyEvent shape from @opentui/core/lib/KeyHandler.

Follow-up to #4996, which introduced the flag.

How did you verify your code works?

  • Traced the key path: parseKittyKeyboard sets key.super = true when Cmd is held (modifier bit 8 in fromKittyMods). The widened condition matches it.
  • Monorepo typecheck passes (pre-push hook ran bun turbo typecheck — 14/14 successful).
  • Manual TUI test on Ghostty / macOS with OPENCODE_EXPERIMENTAL_DISABLE_COPY_ON_SELECT=1: drag-select → Cmd+C copies to clipboard and shows the "Copied to clipboard" toast. Ctrl+C still works (no regression). Without the env var, the existing copy-on-select behavior is unchanged.
  • Note: terminals that don't forward Cmd+C (Terminal.app, Warp, etc.) are unaffected by this change — that's a terminal-side limitation outside this PR's scope.

Screenshots / recordings

N/A — not a visual change.

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

handleSelectionKey only matched event.ctrl, so on macOS with Kitty
Keyboard Protocol (Ghostty, Kitty, WezTerm) Cmd+C arrived as
event.super and fell through to renderer.clearSelection(), wiping the
highlight without copying. Accept meta and super in addition to ctrl.

Fixes anomalyco#27058

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@github-actions github-actions Bot added needs:compliance This means the issue will auto-close after 2 hours. and removed needs:compliance This means the issue will auto-close after 2 hours. labels May 12, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Thanks for updating your PR! It now meets our contributing guidelines. 👍

@alexjoeyyong

Copy link
Copy Markdown

Is this still going to be a thing? I can confirm the bug still exists in the most recent version.

@github-actions

Copy link
Copy Markdown
Contributor

Automated PR Cleanup

Thank you for contributing to opencode.

Due to the high volume of PRs from users and AI agents, we periodically close older PRs using automated criteria so maintainers can focus review time on the most active and community-supported contributions.

This PR was closed because it matched the following cleanup criteria:

  • The PR was created more than 1 month ago
  • The PR had fewer than 2 positive reactions
  • Positive reactions are counted as thumbs-up, heart, celebration, or rocket reactions on the PR

PRs created within the last month are not affected by this cleanup.

If you believe this PR was closed incorrectly, or if you are still actively working on it, please leave a comment explaining why it should be reopened. A maintainer can review and reopen it if appropriate.

Thanks again for taking the time to contribute.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug: OPENCODE_EXPERIMENTAL_DISABLE_COPY_ON_SELECT clears selection on Ctrl/Cmd+C instead of copying

2 participants